#!/bin/bash

#设置全局email
#git config --global user.email "huajie.bao@transsnet.com@transsnet.com"
#设置全局name
#git config --global user.name "baohuajie"
#查看当前目录
SERVICE_DIR=`find ./ -maxdepth 1 -type d`;
#需要更新的分支
echo "请输入新分支名称:"
read new_branch;
echo "新分支是否要push到远程:Y-是,N-否"
read is_push_origin;

for DIR in $SERVICE_DIR
do
	
	#去除./,只pull pc开头的项目
	str="pc"
	result=$(echo $DIR | grep "${str}")
	echo "===============================  $result START ============================================"
	if [[ "$result" != "" ]]; then
		cd /d/work/code/new/$DIR;
		git checkout release/4.0;
		git pull;
		git checkout -b $new_branch;
		if [ "$is_push_origin" == "Y" ]; then
			echo "$result push to origin"
			git push --set-upstream origin $new_branch;
		else
			echo "$result do not need push"
		fi
	fi
	echo "===============================  $result END  ============================================"
done
